package com.shouer.doc.common.util;


import android.content.Context;
import android.os.Environment;

import java.io.File;

/**
 * Created by apple on 15/5/30.
 */
public class SdCardUtils {

    public static boolean isSDCardAvailable() {
        if (Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED)) {
            // sd card 可用
            return true;
        } else {
            // 当前不可用
            return false;
        }
    }

    public static String getSDCardPath() {
        if (Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED)) {
            // sd card 可用
            return Environment.getExternalStorageDirectory().getAbsolutePath();
        } else {
            // 当前不可用
            return "";
        }
    }

    public static String getSdCacheFilePath(Context context, String fileName) {

        StringBuffer filePath = new StringBuffer(context.getExternalCacheDir().getPath()).append(File.separator).append(fileName);

        return filePath.toString();
    }

    public static String getCacheFilePath(Context context, String fileName) {

        StringBuffer filePath = new StringBuffer(context.getCacheDir().getPath()).append(File.separator).append(fileName);

        return filePath.toString();
    }


    public static String getFilePath(Context context)
    {

        return context.getFilesDir().getAbsolutePath();
    }

}
